package src.hash;

import java.util.ArrayList;
import java.util.List;

public class no442 {  //数组中重复的数据

    public List<Integer> findDuplicates(int[] nums) {
        int n = nums.length;
        List<Integer> list = new ArrayList<>();
        int[] hash = new int[n];
        for (int num : nums) {
            hash[num - 1]++;
        }
        for (int i = 0; i < n; i++) {
            if (hash[i] ==2) {
                list.add(i+1);
            }
        }
        return list;
    }
}
